<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>魏远商城</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="shortcut icon" href="/favicon.ico">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">

		<link rel="stylesheet" href="css/sm.css">
		<link rel="stylesheet" type="text/css" href="css/my-order.css" />
		<link rel="stylesheet" type="text/css" href="css/my-order_de.css" />
		<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
		<style type="text/css">
			body {
				background-color: white;
			}
			
			.content {
				background: white;
			}
			
			.bar-nav {
				border-bottom: 1px solid #e7e7e7;
			}
		</style>
	</head>

	<body style="overflow: auto;">
		<header class="bar bar-nav">
			<span class="order-back mui-action-back"><img src="img/back-le.png" height="50%"/></span>
			<a class="button button-link iconfont icon-shuaxin1 pull-right"></a>
			<h1 class="title">我的订单</h1>
			<span class="order-back1 mui-action-back"></span>
		</header>

		<div style="width: 100%;padding-top: 44px;margin: 0 auto;padding-bottom: 80px;">
			<div class="goods-d">
				<div class="goods">
					<!--<div class="top">
						<div></div>
						<div class="top_wa">
							<div class="top_name"><span>白菜</span><span>￥<span>123</span></span></div>
							<div class="top_wa2">
								<div>数量：<span>1</span></div>
								<div class="top_2_z">
									<span class="col refund">退换货</span>								
								</div>
							</div>
							
						</div>
					</div>-->
				</div>
			</div>
			<div class="wu-d">
				<div class="wu">
					<p class="top_3"><span>订单编号：<span class="ordernum"></span></span><span class="ztai"></span></p>
					<!--<div class="middle">
						<span><img src="img/car.png"/></span><span>快递哥正在向您飞奔的路上...</span><span><img src="img/mine-jin.png"/></span>
					</div>-->
					<div class="middle_2">
						<div><img src="img/car_2.png" /></div>
						<div>
							<p><span class="name"></span><span class="phone"></span></p>
							<p class="details"><span class="sheng"></span><span class="detailsss"></span></p>
						</div>
					</div>
				</div>
			</div>
			<div class="buyersay" style="display: none;">
				<div class="middle_2">
						<div><img src="img/buyersayicon.png" /></div>
						<div>
							<p class="buyqianname">买家留言：</p>
							<p class="buyqiansay"></p>
						</div>
				</div>
			</div>
			<div class="pay-wu">
				<div class="pay">
					<div class="middle_3">
						<p class="payway"><span>支付方式</span><span class="payway2">微信支付</span></p>
						<p class="goinfor"><span>配送信息</span><span class="whkd">中通速递</span></p>
						<!--<p class="fainfor"><span>发票信息</span><span>不开发票</span></p>-->
						<p class="allpri"><span>商品总额</span><span class="col">￥<span class="allcol"></span></span></p>
						<p class="allpri youhuip" style="display: none;"><span>优惠券优惠金额</span><span class="col">￥<span class="youhuipri"></span></span></p>
						<p class="yunfei"><span>+运费</span><span>￥<span class="yuncol"></span></span>
						</p>
					</div>
					<div class="middle_4">
						<p><span>实付款</span><span class=" col">￥<span class="shicol"></span></span>
						</p>
						<p>下单时间：<span class="times"></span></p>
					</div>
				</div>
			</div>
		</div>

		<div class="foot">
			<span class="backor"></span><span class="optai"></span>
		</div>
		<div class="black-all">
			<div class="wraap">
				<div class="dcancel"><span class="cancel"><img src="img/chacha.png"></span></div>
				<div class="wraapah">

				</div>
			</div>
		</div>
		<script src="js/jquery-3.1.1.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<!--<script src="js/mui.min.js" type="text/javascript" charset="UTF-8"></script>-->
		<script src="js/url.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
		
//		mui.plusReady(function() {
				allpageinfo();
//			})
			$('.black-all').css('height', document.body.clientHeight + 'px');

			$('.cancel').on('tap', function() {
				$('.black-all').css('display', 'none');
				$('.wraapah').html('');
			})

			/*查看组合商品详情*/

			function lookzdeta() {
//				plus.nativeUI.showWaiting();
				$.ajax({
					type: "post",
					url: ur + '/mobilemember/frontOrder/showComProductList',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.token
					},
					data: {
						"comSkuIds": localStorage.zhsdeta
					},
					success: function(data) {
//                      plus.nativeUI.closeWaiting();
						if(data.result.meta.code == 200) {
							$('.black-all').css('display', 'block');
							for(var i = 0; i < data.result.data.length; i++) {
								var b = data.result.data[i].mainImg;
								console.log(b.indexOf(',') + '逗号索引值');
								var m = b.indexOf(',');
								if(m != '-1') {
									var mainImg = b.substring(0, m);
								} else {
									mainImg = b;
								}
								var divd = $('<div class="top">' +
									'<div style="background-image: url(' + picur + mainImg + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></div>' +
									'<div class="top_wa">' +
									'<div class="top_name"><span>' + data.result.data[i].productVO.shortname + '</span><span>￥<span>' + data.result.data[i].newPrice + '</span></span></div>' +
									'<div class="ztop_wa2">' +
									'<div><span class="dhowjian">' + data.result.data[i].skuSize + '</span></div>' +

									'</div>' +

									'</div>' +
									'</div>');

								$('.wraapah').append(divd);
							}
						}
					},
					error: function(data) {
//                     plus.nativeUI.closeWaiting();
					}
				});
			}
//           allpageinfo()
			/*获取页面信息接口*/
			function allpageinfo(){
//				plus.nativeUI.showWaiting();
				var allhow = 0;
				var allprice = 0;
				$.ajax({
					url: ur + '/mobilemember/frontOrder/getOrderDetail',
					type: 'POST',
					dataType: 'json',
					headers: {
						"X-Token": localStorage.token
					},
					data: {
						"orderVO.id": localStorage.deorderid
					},
					success: function(data) {
//						plus.nativeUI.closeWaiting();
						console.log(data);
						//						alert(data.obInfo.status);
						if(data.finalCode == 200) {
							
							if(data.obInfo.leaveWord!=""){
								
								$('.buyersay').css('display','block');
								$('.buyqiansay').text(data.obInfo.leaveWord);
							}
							
							
							
							//							alert(11);
							$('.howtimes').text()
							$('.sheng').text(data.obInfo.area);
							$('.detailsss').text(data.obInfo.detail);
							$('.name').text(data.obInfo.reciver);
							$('.phone').text(data.obInfo.phone);
							$('.ordernum').text(data.obInfo.orderNum);
							$('.whkd').text(data.obInfo.expressName);
//							$('.allcol').text(data.obInfo.productTotalPrice);
							$('.optai').attr('tai', data.obInfo.status);
							$('.payway2').text(data.obInfo.typePay);
							var time = data.obInfo.createTime;
							$('.times').text(time.replace('T', '  '));
							if(data.obInfo.freight == null) {
								$('.yuncol').text(0);
							} else {
								$('.yuncol').text(data.obInfo.freight);
							}
							if(data.obInfo.orderProductList.length > 0) {
								for(var i = 0; i < data.obInfo.orderProductList.length; i++) {
									var b = data.obInfo.orderProductList[i].skuProductVO.mainImg;
									console.log(b.indexOf(',') + '逗号索引值');
									var m = b.indexOf(',');
									if(m != '-1') {
										var mainImg = b.substring(0, m);
									} else {
										mainImg = b;
									}

									//								 var divd = $('<div class="top">'+
									//									'<div style="background-image: url('+picur+data.obInfo.orderProductList[i].skuProductVO.mainImg+');background-position: center;background-repeat: no-repeat;background-size: cover;"></div>'+
									//									'<div class="top_2">'+
									//										'<p><span>'+data.obInfo.orderProductList[i].skuProductVO.longname+'</span><span>￥'+data.obInfo.orderProductList[i].skuProductVO.newPrice+'</span></p>'+
									//										'<p><span>数量：<span class="dhowjian">'+data.obInfo.orderProductList[i].amount+'</span></span><span class="col refund" id="'+data.obInfo.orderProductList[i].productSkuId+'">退换货</span></p>'+
									//									'</div>'+
									//								    '</div>');
//									alert(data.obInfo.orderProductList[i].skuProductVO.id);
									var divd = $('<div class="top" id="'+data.obInfo.orderProductList[i].skuProductVO.id+'"  toDetails="'+data.obInfo.orderProductList[i].skuProductVO.productId+'">' +
										'<div class="picture" style="background-image: url(' + picur + mainImg + ');background-position: center;background-repeat: no-repeat;background-size: cover;"></div>' +
										'<div class="top_wa">' +
										'<div class="top_name"><span>' + data.obInfo.orderProductList[i].skuProductVO.longname + '</span><span>￥<span>' + data.obInfo.orderProductList[i].price + '</span></span></div>' +
										'<div class="size"><span>' + data.obInfo.orderProductList[i].size + '</span></div>'+
										'<div class="top_wa2">' +
										'<div class="size">数量：<span class="dhowjian">' + data.obInfo.orderProductList[i].amount + '</span></div>' +
										'<div class="top_2_z' + i + ' top_2_z">' +
										//								'<span class="col refund" id="'+data.obInfo.orderProductList[i].productSkuId+'"></span>'+							
										'</div>' +
										'</div>' +

										'</div>' +
										'</div>');

									$('.goods').append(divd);

									if(data.obInfo.orderProductList[i].comSkuIds != "null") {
										
										var evalu = $('<span class="col lookdeta" id="' + data.obInfo.orderProductList[i].comSkuIds + '">查看详情</span>');

										$('.top_2_z' + i + '').append(evalu);
									}

									allhow = allhow + data.obInfo.orderProductList[i].amount;
									
									allprice = allprice + data.obInfo.freight + data.obInfo.orderProductList[i].amount * data.obInfo.orderProductList[i].price;
//									$('.shicol').text(allprice.toFixed(2));
									$('.shicol').text(data.obInfo.orderPay);
									$('.allcol').text(allprice);
//									alert(allprice);
//									alert(data.obInfo.orderPay);
									
									
									
									localStorage.allhow = allhow;
                                     
									if(data.obInfo.status == 1) {
										$('.ztai').text('待付款');
										$('.optai').text('立即支付');
										//									$('.top_2_z').css('display','none');
										$('.backor').text('取消订单');
									} else if(data.obInfo.status == 2||data.obInfo.status == 19) {
										//								var evalu = $('<span class="col refundmon" id="'+data.obInfo.orderProductList[i].productSkuId+'">退款</span>');
										//								    $('.top_2_z'+i+'').append(evalu);
										$('.ztai').text('待发货');
										$('.optai').text('提醒发货');
										$('.backor').text('申请退款');
										//									$('.top_2_z').css('display','none');
									} else if(data.obInfo.status == 3) {
										$('.backor').text('查看物流');
										$('.ztai').text('待收货');
										$('.optai').text('确认收货');
										//									$('.top_2_z').css('display','none');
									} else if(data.obInfo.status == 5) {
										var evalu = $('<span class="col refund" id="' + data.obInfo.orderProductList[i].productSkuId + '">退货</span>' +
											'<span class="col evaluate" id="' + data.obInfo.orderProductList[i].productSkuId + '">去评论</span>');
										$('.top_2_z' + i + '').append(evalu);
										$('.backor').text('删除订单');
										$('.optai').css('display', 'none');
										$('.ztai').css('display', 'none');
									} else if(data.obInfo.status == 9) {
										var evalu = $('<span class="col refund" id="' + data.obInfo.orderProductList[i].productSkuId + '">退货</span>' +
											'<span class="col evaluate" id="' + data.obInfo.orderProductList[i].productSkuId + '">追加评论</span>');
										$('.top_2_z' + i + '').append(evalu);
										$('.backor').text('删除订单');
										$('.optai').css('display', 'none');
										$('.ztai').css('display', 'none');
									}

								}
								if(allprice!=data.obInfo.orderPay){
//										alert(11);
										$('.youhuip').css('display','block');
										$('.youhuipri').text((allprice-data.obInfo.orderPay).toFixed(2));
									}
							}
						}
					},
								error:(function(data){
//									plus.nativeUI.closeWaiting();
								})
				})
			}

			$('.goods').on('tap', '.lookdeta', function() {
				//		       	   alert($(this).attr('id'));
				//		       	   $(this).attr('id');

				localStorage.zhsdeta = $(this).attr('id');
				//		       	   alert(localStorage.zhsdeta );
				lookzdeta();

			})
			/*6.5*/
			$('.goods-d').on('tap','.picture', function() {
//								alert($(this).attr('id'));
				href('details.html', $(this).parent().attr('toDetails'));
			});
			function href(a, c) {
				localStorage.whereId = c;
				mui.openWindow({
					url: a,
					show: {
						aniShow: 'pop-in'
					}
				})
			}
			/*结束*/
			$('.goods').on('tap', '.refund', function() {
				//		       	   alert($(this).attr('id'));
				//		       	   $(this).attr('id');
				localStorage.reskuid = $(this).attr('id');
				localStorage.backhow = $(this).parents('.top').find('.dhowjian').text();

				mui.openWindow({
					url: 'refund.html',
					id: 'refund',
					show: 'pop-in'
				});
			})

			$('.goods').on('tap', '.refundmon', function() {
				//		       	   alert($(this).attr('id'));
				//		       	   $(this).attr('id');
				localStorage.reskuid = $(this).attr('id');
				localStorage.backhow = $(this).parents('.top').find('.dhowjian').text();

				mui.openWindow({
					url: 'refundmon.html',
					id: 'refundmon',
					show: 'pop-in'
				});
			})

			$('.goods').on('tap', '.evaluate', function() {
				localStorage.sureorderid = localStorage.deorderid;
				localStorage.spskuid = $(this).attr('id');
				mui.openWindow({
					url: 'evaluate.html',
					id: 'evaluate',
					show: 'pop-in'
				});
			});
			/*第一个按钮点击*/
//			$('.optai').on('tap', function(event) {
//				var tai = $('.optai').attr('tai');
//				if(tai == 19){
//					/*发货提醒*/
//					var thisid2 = $(this).parents('.order').attr('oid');
//					console.log($(this));
//					//                    alert(thisid);
//					var all2 = $(this).parents('.order');
//					var btnArray = ['否', '是'];
//					mui.confirm('确认提醒发货，确认？', '魏远商城', btnArray, function(e) {
//						if(e.index == 1) {
//							//				alert(thisid);
//							$.ajax({
//								url: ur + '/mobilemember/frontOrderOperation/remind',
//								type: 'post',
//								headers: {
//									"X-Token": localStorage.token
//								},
//								dataType: 'json',
//								data: {
//									"orderByRemindId": thisid2,
//									/*"id": '40288051594f367a015963128b240033',*/
//								},
//								success: function(data) {
//									console.log(data);
//									//							all.fadeOut(1000);
//									mui.toast('已为您发送提醒信息');
//									updataallsx();
//								},
//								error: function(data) {
//									console.log(data);
//								}
//							})
//
//						}
//					})
//				}
//			})
			$('.backor').on('tap', function(event) {
				//				alert($('.optai').attr('tai'));
				event.stopPropagation();
				//				 event.stopPropagation();
				var tai = $('.optai').attr('tai');
				if(tai == 1) {
					/*取消订单*/
					var thisid = localStorage.deorderid;
					console.log($(this));
					//                    alert(thisid);
					//				      var all = $(this).parents('.order');
					var btnArray = ['否', '是'];
					mui.confirm('确认取消订单，确认？', '魏远商城', btnArray, function(e) {
						if(e.index == 1) {
							//				alert(thisid);
							$.ajax({
								url: ur + '/mobilemember/frontOrderOperation/cancel',
								type: 'post',
								headers: {
									"X-Token": localStorage.token
								},
								dataType: 'json',
								data: {
									"orderVO.id": thisid,
									/*"id": '40288051594f367a015963128b240033',*/
								},
								success: function(data) {
									console.log(data);
									//							all.fadeOut(1000);
									mui.toast('取消订单成功');
								},
								error: function(data) {
									console.log(data);
								}
							})
						}
					})
				}
//				else if(tai == 2 || tai == 19) {
//					/*发货提醒*/
//					var thisid2 = $(this).parents('.order').attr('oid');
//					console.log($(this));
//					//                    alert(thisid);
//					var all2 = $(this).parents('.order');
//					var btnArray = ['否', '是'];
//					mui.confirm('确认提醒发货，确认？', '魏远商城', btnArray, function(e) {
//						if(e.index == 1) {
//							//				alert(thisid);
//							$.ajax({
//								url: ur + '/mobilemember/frontOrderOperation/remind',
//								type: 'post',
//								headers: {
//									"X-Token": localStorage.token
//								},
//								dataType: 'json',
//								data: {
//									"orderByRemindId": thisid2,
//									/*"id": '40288051594f367a015963128b240033',*/
//								},
//								success: function(data) {
//									console.log(data);
//									//							all.fadeOut(1000);
//									mui.toast('已为您发送提醒信息');
//									updataallsx();
//								},
//								error: function(data) {
//									console.log(data);
//								}
//							})
//
//						}
//					})
//				}
				else if(tai==2||tai==19){
//                	var thisid2 = $(this).parents('.order').attr('oid');
						localStorage.backmonm = localStorage.deorderid;
						console.log($(this));
						mui.openWindow({
							url: 'refoundmon.html',
							id: 'refoundmon',
							show: 'pop-in'
						});								 	
				}
				else if(tai == 3) {
					/*查看物流*/
					localStorage.lookorderid = localStorage.deorderid;
					mui.openWindow({
						url: 'my-logistics.html',
						id: 'my-logistics',
						show: 'pop-in'
					});

				} else if(tai == 5) {
					/*删除订单*/
					var thisid5 = localStorage.deorderid;
					console.log($(this));
					//                    alert(thisid);
					var all5 = $(this).parents('.order');
					var btnArray = ['否', '是'];
					mui.confirm('确认删除订单，确认？', '魏远商城', btnArray, function(e) {
						if(e.index == 1) {
							//						alert(thisid);
							$.ajax({
								url: ur + '/mobilemember/frontOrderOperation/orderByDel',
								type: 'post',
								headers: {
									"X-Token": localStorage.token
								},
								dataType: 'json',
								data: {
									"orderVO.id": thisid5,
									/*"id": '40288051594f367a015963128b240033',*/
								},
								success: function(data) {
									console.log(data);
									//							all.fadeOut(1000);
									mui.toast('删除订单成功');
								},
								error: function(data) {
									console.log(data);
								}
							})
						}
					})
				} else if(tai == 11) {
					/*删除订单*/
					var thisid11 = localStorage.deorderid;
					console.log($(this));
					//                    alert(thisid);
					//				      var all11 = $(this).parents('.order');
					var btnArray = ['否', '是'];
					mui.confirm('确认删除订单，确认？', '魏远商城', btnArray, function(e) {
						if(e.index == 1) {
							//				alert(thisid);
							$.ajax({
								url: ur + '/mobilemember/frontOrderOperation/orderByDel',
								type: 'post',
								headers: {
									"X-Token": localStorage.token
								},
								dataType: 'json',
								data: {
									"orderVO.id": thisid11,
									/*"id": '40288051594f367a015963128b240033',*/
								},
								success: function(data) {
									console.log(data);
									all11.fadeOut(1000);
									mui.toast('删除订单成功');
								},
								error: function(data) {
									console.log(data);
								}
							})
						}
					})
				}
			})

			/*第二个按钮点击*/
			$('.foot').on('tap', '.optai', function(event) {
				event.stopPropagation();
				//				alert($(this).attr('tai'));
				var tai = $(this).attr('tai');
				if(tai == 1) {
					/*去到付款*/
					localStorage.alltimes = localStorage.allhow;
					localStorage.allpriceall = $('.shicol').text();
					localStorage.sureorderid = localStorage.deorderid;
					//				 	alert(localStorage.alltimes );
					//				 	alert(localStorage.allpriceall);
					mui.openWindow({
						url: 'sure.html',
						id: 'sure',
						show: 'pop-in'
					});

				} else if(tai == 2||tai ==19) {

					/*取消订单*/
					var thisid2 = $(this).attr('oid');
					console.log($(this));
					//                    alert(thisid);
					//				      var all2 = $(this).parents('.order');
					var btnArray = ['否', '是'];
					mui.confirm('确认提醒发货，确认？', '魏远商城', btnArray, function(e) {
						if(e.index == 1) {
							//				alert(thisid);
							$.ajax({
								url: ur + '/mobilemember/frontOrderOperation/remind',
								type: 'post',
								headers: {
									"X-Token": localStorage.token
								},
								dataType: 'json',
								data: {
									"orderVO.id": thisid2,
									/*"id": '40288051594f367a015963128b240033',*/
								},
								success: function(data) {
									console.log(data);
									//							all.fadeOut(1000);
									mui.toast('已为您发送提醒信息');
								},
								error: function(data) {
									console.log(data);
								}
							})
						}
					})
				} else if(tai == 3) {
					/*确认收货*/
					var thisid3 = localStorage.deorderid;
					console.log($(this));
					//                    alert(thisid);
					var all3 = $(this).parents('.order');
					var btnArray = ['否', '是'];
					mui.confirm('确认收货，确认？', '魏远商城', btnArray, function(e) {
						if(e.index == 1) {
							//				alert(thisid);
							$.ajax({
								url: ur + '/mobilemember/frontOrderOperation/confirmReceipt',
								type: 'post',
								headers: {
									"X-Token": localStorage.token
								},
								dataType: 'json',
								data: {
									"orderVO.id": thisid3,
									/*"id": '40288051594f367a015963128b240033',*/
								},
								success: function(data) {
									console.log(data);
									//							all.fadeOut(1000);
									mui.toast('确认收货成功');
									mui.back();
								},
								error: function(data) {
									console.log(data);
								}
							})
						}
					})
				} else if(tai == 5) {
					localStorage.sureorderid = localStorage.deorderid;
					mui.openWindow({
						url: 'evaluate.html',
						id: 'evaluate',
						show: 'pop-in'
					});
				}

			})
		</script>
	</body>

</html>